package com.baomidou.mybatisplus;

import com.baomidou.mybatisplus.domain.User;
import com.baomidou.mybatisplus.mapper.UserMapper;
import com.baomidou.mybatisplus.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Add {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserService userService;

    /**
     * mapper测试
     */
    @Test
    public void addUser() {
        User user = new User();
//        user.setId(1L);
        user.setName("zs");
        user.setAge(10);
        userMapper.insert(user);
    }

    /**
     * service测试
     */
    @Test
    public void addUser1() {
        for (int i = 0; i < 30; i++) {
            User user = new User();
            user.setName("ls");
            user.setAge(20);
            userService.save(user);
        }
    }

    /**
     * domain测试
     */
    @Test
    public void addUser2() {
        User user = new User();
        user.setName("ww");
        user.setAge(30);
        user.insert();
    }

}
